#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<sstream>
using namespace std;
//随便写写吧
//凑个旅店
// 호텔 대실

//将HH:MM时间格式转换为分钟数
int timeToMiuntes(const string& time)
{
    int hours = stoi(time.substr(0,2));
    //stoi的作用是将字符串转换为整数的作用

    int minutes = stoi(time.substr(3,2));
    return hours * 60 + minutes;
}

int solution(vector<vector<string>> book_time)
{
    //将预定时间转换为开始时间和结束时间 - 加清扫时间的分钟数
    vector<pair<int,int>>times;
    for(const auto& booking:book_time)
    {
        int start = timeToMiuntes(booking[0]);
        int end = timeToMiuntes(booking[1]) + 10;//加上清扫时间
        times.emplace_back(start,end);
    }

    //按开始时间排序
    sort(times.begin(),times.end());

    //使用两个小堆来追踪每个房间的当前结束时间
    priority_queue<int,vector<int>,greater<int>>room_end_times;

    for(const auto& time :times)
    {
        int start = time.first;
        int end = time.second;

        //如果有房间空闲- 堆顶结束时间<=当前预定的时间，更新房间结束时间
        if(!room_end_times.empty() && room_end_times.top() <= start)
        {
            room_end_times.pop(); //取出该房间
        }
        //将当前预定的结束时间加入堆中 新增或更新房间
        room_end_times.push(end);
    }
    //堆的大小即为所需的最少房间数
    return room_end_times.size();
}
int main()
{
    vector<vector<string>>book_time1 = 
    {
        {"15:00", "17:00"},
        {"16:40", "18:20"},
        {"14:20", "15:20"},
        {"14:10", "19:20"},
        {"18:20", "21:20"}
    };
        vector<vector<string>> book_time2 = {
        {"09:10", "10:10"},
        {"10:20", "12:20"}
    };

    vector<vector<string>> book_time3 = {
        {"10:20", "12:30"},
        {"10:20", "12:30"},
        {"10:20", "12:30"}
    };

    cout << "Test Case 1: " << solution(book_time1) << endl; // Expected: 3
    cout << "Test Case 2: " << solution(book_time2) << endl; // Expected: 1
    cout << "Test Case 3: " << solution(book_time3) << endl; // Expected: 3

    cout<<endl;
    return 0;
}